package com.gf.demo.mongodemo.entity;

import com.gf.framework.mongo.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.CompoundIndexes;
import org.springframework.data.mongodb.core.mapping.Document;

import java.time.LocalDate;

/**
 * @author gaofei
 * @date 2022/5/28 11:33
 */
@EqualsAndHashCode(callSuper = false)
@Data
@Document(collection = "Student")
@CompoundIndexes(value = {
        // 学号+考试场次，作为一个唯一索引，每个学生每个学号，单场考试只能录入一次成绩
        @CompoundIndex(name = "s_e_unique", def = "{'studentId' : 1, 'examSession' : 1}", unique = true)
})
public class Student extends BaseEntity {
    @ApiModelProperty("学号")
    private String studentId;
    @ApiModelProperty("姓名")
    private String name;
    @ApiModelProperty("年龄")
    private Integer age;
    @ApiModelProperty("出生日期")
    private LocalDate birth;
    @ApiModelProperty("考试场次")
    private String examSession;
    @ApiModelProperty("数学成绩")
    private Integer mathMark;
    @ApiModelProperty("英语成绩")
    private Integer englishMark;
}
